﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LsKeyboardCore
{
    public class SpecialLabelKeys : LabelEx
    {
        public override bool IsDown 
        {
            get
            {
                return isDown;
            }
            set
            {
                if (isDown != value)
                {
                    isDown = value;
                    if (isDown)
                    {
                        this.BackColor = KeyBoardAppearance.KeyBoardMouseDownBackColor;
                    }
                    else
                    {
                        this.BackColor = KeyBoardAppearance.KeyBoardControlKeyBackColor;
                    }
                }
            }
        }

        public SpecialLabelKeys() : base()
        {
            base.AutoSize = false;
            this.Size = new Size(50, 50);
            this.Font = KeyBoardAppearance.GetFont();
            this.ForeColor = KeyBoardAppearance.ForeColor;
            this.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;//文本居中
            this.BackColor = KeyBoardAppearance.KeyBoardControlKeyBackColor;
        }
        /// <summary>
        /// 鼠标进入
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseEnter(EventArgs e)
        {
            base.OnMouseEnter(e);
            if (!IsDown)
            {
                this.BackColor = KeyBoardAppearance.KeyBoardControlKeyMouseEnterBackColor;
            }
        }
        /// <summary>
        /// 鼠标离开
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);
            if (!IsDown)
            {
                this.BackColor = KeyBoardAppearance.KeyBoardControlKeyBackColor;
            }
        }
        /// <summary>
        /// 鼠标按下
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);
            if (!IsDown)
            {
                this.BackColor = KeyBoardAppearance.KeyBoardMouseDownBackColor;
            }
        }
        /// <summary>
        /// 鼠标弹起
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            if (!IsDown)
            {
                this.BackColor = KeyBoardAppearance.KeyBoardControlKeyBackColor;
            }
        }
    }
}
